package com.tyrone.leetcode.weekgame;

import java.util.Arrays;

/**
 * @author yelong.xie
 * @date 2024/1/14 10:33
 */
public class MaxFrequencyElements {
    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.maxFrequencyElements(new int[]{1,2,3,4,5}));

    }
    public static class Solution {
        public int maxFrequencyElements(int[] nums) {
            if (nums == null) return 0;
            int maxF  = 0 ;
            int[] arr = new int[101];
            int result = 0;
            for (int num : nums) {
                arr[num]++;
                maxF = Math.max(maxF,arr[num]);
            }
            for (int i = arr.length-1; i>=0; i--) {
                if (arr[i] == maxF )
                    result+=maxF;
            }
            return result;
        }
    }
}
